package com.sunlands.deskmate.message.handler.storager.interceptor.impl;

import com.sunlands.deskmate.message.entity.Messages;
import com.sunlands.deskmate.message.handler.storager.interceptor.Interceptor;
import com.sunlands.deskmate.sstwds.ContentSecCheck;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 敏感词过滤，直接替换掉对应的敏感词
 */
@Order(100)
@Slf4j
@Component
public class SensitiveWordInterceptor implements Interceptor {

    @Autowired
    private ContentSecCheck contentSecCheck;

    @Override
    public boolean interceptor(Messages msgEntity) {
        if (StringUtils.isNotBlank(msgEntity.getMessage())) {
            msgEntity.setMessage(contentSecCheck.filterSensitiveWords(msgEntity.getMessage()));
        }
        return true;
    }
}